
/***
 *
    int src[] = {
            141,141,141,143,144,165,144,141,128,140,141,141,140,140,140,140,140,141,143,143,143,144,144,144,144,144,144,144,143,143,145,143,143,141,141,141,141,141,141,141,140,140,140,140,141,141,140,140,140,140,139,139,137,137,139,139,140,140,141,144,144,141,140,139,137,140,140,141,141,141,141,143,141,130,141,156,140,140,140,141,141,141,141,141,141,141,140,140,139,139,139,139,137,137,140,140,141,150,160,156,
            140,134,135,136,137,137,137,137,139,140,140,141,141,141,141,141,143,144,145,147,150,153,169,148,131,144,150,163,153,143,131,143,141,141,140,141,141,143,143,143,143,144,145,148,145,145,145,145,144,144,144,143,141,141,140,140,141,141,140,141,141,136,129,140,160,165,165,141,129,141,141,141,140,140,141,141,143,143,144,143,144,144,144,141,141,144,141,141,141,141,143,144,143,141,141,141,140,140,140,141,
            143,144,144,145,145,147,145,145,144,145,144,143,143,143,141,140,140,140,141,140,139,140,140,140,140,140,140,140,129,130,140,141,143,165,140,137,130,134,136,141,143,143,144,143,144,143,144,144,144,145,147,145,145,144,144,134,145,159,145,145,147,147,148,148,147,147,147,147,147,145,145,145,145,132,129,134,145,145,158,171,171,169,150,145,144,144,144,144,143,132,134,145,144,144,143,144,144,145,144,145,
            147,148,148,150,132,144,159,145,141,141,141,141,141,141,140,141,141,141,141,143,141,143,143,143,143,144,143,143,143,143,144,144,145,143,141,141,141,141,141,144,145,167,144,141,127,140,140,140,139,139,139,140,139,140,141,141,141,141,141,141,141,141,140,140,141,141,144,141,141,140,140,140,140,141,141,141,141,141,141,141,141,140,139,137,137,137,137,137,137,137,137,139,140,143,143,145,144,141,141,140,
            139,140,141,141,141,141,141,141,141,130,140,155,141,141,141,143,143,144,145,144,143,140,140,140,140,140,140,139,139,139,140,141,144,153,165,160,144,140,140,140,141,143,141,141,141,141,144,145,144,143,141,143,143,144,144,148,150,154,169,148,130,145,151,165,155,145,135,145,145,144,143,143,141,141,144,145,145,145,148,148,145,145,145,145,145,145,145,144,143,143,141,141,141,141,141,143,141,135,126,137,
            158,163,163,141,130,144,144,144,141,141,141,141,144,144,144,141,141,141,141,141,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,141,141,144,144,145,145,148,145,145,145,145,144,143,141,141,140,139,139,139,139,137,137,139,140,140,139,140,140,139,127,128,136,139,141,163,137,136,129,132,134,139,140,141,143,143,144,144,145,145,145,144,144,144,144,144,144,132,144,160,145,147,148,148,148,147,
            145,145,145,145,145,145,144,144,144,131,127,132,144,144,154,167,167,163,145,141,143,143,143,141,141,130,132,144,144,143,144,144,145,145,145,147,147,145,147,147,130,143,158,144,141,140,140,141,141,144,141,141,141,143,143,144,144,144,144,144,144,143,141,141,141,143,143,144,145,144,143,143,143,144,145,145,145,165,144,141,127,140,141,140,140,140,140,140,140,141,144,144,145,147,147,145,145,147,144,144,
            144,144,147,145,144,141,141,141,140,141,141,143,141,143,141,141,141,140,140,140,140,140,140,140,140,140,140,140,141,141,144,148,147,144,143,140,139,140,141,143,143,143,144,144,141,131,141,156,141,141,141,144,144,143,143,141,141,139,139,140,140,141,141,141,140,140,141,141,144,153,163,160,141,137,139,140,140,140,140,140,140,140,140,141,141,141,141,141,143,144,144,147,150,153,169,148,130,145,153,167,
            155,145,134,145,144,143,141,141,140,140,141,143,144,145,147,148,145,144,144,144,143,143,143,141,141,141,140,140,140,140,140,140,140,134,125,137,158,165,165,143,130,141,141,141,140,140,141,141,143,144,144,143,143,144,141,140,140,140,140,140,139,139,139,139,137,139,139,139,139,137,137,139,140,140,141,141,144,145,144,144,144,144,143,141,140,140,140,140,140,140,140,139,137,137,137,137,137,137,137,137,
            126,126,136,139,141,165,140,137,129,132,135,140,141,143,144,144,144,144,144,144,144,144,144,144,144,144,144,134,145,163,150,150,148,148,148,147,147,147,147,145,145,145,145,145,145,132,131,136,148,150,163,173,173,171,150,145,145,145,145,145,144,132,134,144,144,143,143,145,145,148,145,147,147,147,148,148,132,145,161,147,144,144,143,143,143,143,143,144,144,144,144,144,144,144,144,144,144,144,144,144,
            143,144,144,144,145,144,144,144,144,143,143,143,144,163,143,141,128,141,144,143,141,140,140,140,141,143,144,144,144,144,145,145,144,144,143,143,143,141,144,141,141,140,140,140,140,141,141,141,141,141,141,141,140,141,140,140,140,140,140,140,139,139,139,139,140,140,141,145,145,143,141,140,137,140,140,141,140,140,140,141,140,129,140,154,140,140,140,141,141,141,141,141,141,140,140,140,140,140,140,140,
            139,139,140,141,144,153,163,160,143,139,139,139,139,139,139,140,139,139,140,140,140,140,140,140,141,141,141,144,147,150,163,145,128,144,150,165,153,144,132,144,143,141,141,141,141,141,143,144,144,144,145,145,144,143,143,143,141,141,141,141,141,144,141,141,140,141,140,141,141,135,126,137,158,165,165,141,129,141,141,141,141,141,141,144,144,145,147,145,144,143,141,140,140,140,140,140,140,140,140,140
    };
    int src2[] = {
            147,147,148,148,147,147,147,147,147,147,147,147,145,145,150,150,150,145,147,147,150,148,151,151,150,151,151,151,151,151,151,151,150,150,150,150,150,150,150,150,151,151,151,151,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,151,150,150,150,150,150,145,145,145,145,145,147,145,144,144,141,140,137,136,135,134,130,130,128,127,125,122,120,120,118,116,115,
            114,112,108,107,104,102,100,98,97,96,94,92,91,91,93,96,97,99,101,102,103,103,105,105,107,108,111,111,113,116,118,119,123,128,129,129,130,134,135,139,141,143,144,147,151,150,153,155,155,158,158,160,161,163,163,167,167,169,169,167,165,165,165,163,163,163,163,163,161,161,161,159,160,160,161,160,160,161,161,158,158,160,156,156,156,156,158,156,156,155,153,153,151,151,151,153,151,151,151,151,
            151,150,150,150,150,151,151,151,151,151,151,151,151,151,151,153,151,151,151,151,151,151,151,151,151,151,153,151,151,151,151,150,150,151,151,153,151,151,151,150,150,150,150,150,150,151,153,151,151,150,150,150,150,150,150,150,150,150,151,151,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,150,151,151,151,151,151,151,151,150,150,150,150,150,150,150,150,151,151,151,151,
            150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,151,150,150,150,150,150,145,145,145,147,147,148,148,148,148,147,147,145,145,145,148,148,148,144,144,144,148,144,148,147,147,148,148,148,148,148,148,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,150,150,148,148,148,148,148,148,148,148,150,150,151,151,150,150,150,150,151,151,151,151,151,
            151,150,150,150,147,147,145,145,145,145,144,144,144,144,144,143,140,137,136,132,132,130,129,127,125,122,120,120,118,116,117,115,112,111,107,104,102,101,99,97,95,94,93,94,95,97,97,99,99,101,101,104,107,108,109,111,113,113,115,118,119,121,124,127,130,130,131,135,136,139,143,145,145,148,151,151,155,156,156,160,160,161,165,165,165,167,167,165,165,165,165,167,165,165,165,163,163,163,161,161,
            161,161,163,161,161,158,158,158,158,156,156,156,155,154,156,156,155,153,153,153,153,153,151,151,151,151,150,150,150,150,150,150,150,151,151,151,150,151,151,151,151,151,151,151,150,150,150,150,150,150,150,150,151,151,151,151,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,151,150,150,150,150,150,150,150,150,150,150,151,151,151,151,150,150,150,150,150,
            148,148,148,148,148,148,148,148,148,147,147,148,148,148,148,148,148,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,150,150,148,148,148,148,148,148,148,148,150,150,151,151,150,150,150,150,151,151,151,151,151,151,150,150,150,147,147,145,147,147,147,147,148,148,150,151,151,150,148,151,150,150,147,147,147,150,145,150,150,150,150,151,151,151,153,153,151,151,153,151,151,151,151,153,153,
            153,151,150,150,150,150,150,151,151,151,151,151,151,150,150,150,150,151,151,151,151,151,151,151,151,151,151,153,151,151,151,151,151,151,148,148,148,148,148,148,145,144,144,141,140,140,139,139,137,134,134,130,129,127,125,122,121,122,121,119,117,114,111,108,105,103,101,99,98,96,95,93,91,92,93,96,97,98,99,101,101,103,105,106,107,109,112,113,115,119,119,122,122,127,129,130,131,135,136,139,
            140,141,143,145,150,150,153,155,156,160,159,161,161,163,163,165,165,165,165,163,163,163,163,163,163,163,163,163,161,161,161,160,160,161,161,160,160,158,158,156,156,156,155,155,154,155,154,155,155,154,155,153,151,151,151,151,148,148,148,148,148,148,148,148,148,147,147,148,148,148,148,148,148,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,150,150,148,148,148,148,148,148,148,148,150,
            150,151,151,150,150,150,150,151,151,151,151,151,151,150,150,150,150,150,150,150,150,150,150,151,151,153,153,153,151,151,151,150,150,150,150,150,150,150,150,150,150,150,151,151,151,153,153,151,151,153,151,151,151,151,153,153,153,151,150,150,150,150,150,151,151,151,151,151,151,150,150,150,150,151,151,151,151,151,151,151,151,151,151,153,151,151,151,151,151,151,148,148,148,150,150,150,148,148,148,147,
            147,148,148,150,151,151,151,147,147,147,150,147,150,151,153,151,151,150,150,150,150,150,150,150,150,150,151,151,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,151,151,151,150,151,151,151,151,151,151,151,150,150,150,150,150,150,150,150,148,148,148,147,145,145,144,143,143,141,140,137,136,135,134,131,131,129,128,127,125,122,122,120,119,118,117,115,111,109,105,103,100,98,97,96,
            94,93,91,93,94,97,97,99,99,101,101,103,104,105,107,108,111,111,113,116,117,118,120,124,126,127,128,131,132,136,139,140,141,144,150,150,153,155,154,158,158,160,163,165,165,165,165,163,163,161,161,161,161,161,161,163,163,165,163,161,161,160,160,161,161,160,160,159,160,156,156,156,155,155,155,155,154,153,153,154,155,156,155,155,153,153,151,150,150,150,150,150,150,150,150,150,150,150,151,151
    };
    int src3[] = {
            156,155,153,153,153,153,155,156,156,155,155,155,154,156,158,158,156,156,156,156,156,156,156,156,156,156,156,158,156,156,156,156,158,158,158,158,156,156,155,154,155,155,155,156,158,158,158,158,156,156,156,158,156,156,156,156,156,155,154,155,153,153,153,155,155,156,156,156,156,158,158,158,158,156,156,156,156,155,153,153,151,153,153,155,156,156,156,156,156,155,154,155,155,155,155,154,155,155,155,155,
            156,154,156,156,156,156,156,156,156,156,156,156,156,156,156,158,156,156,156,156,156,154,156,158,158,156,156,158,156,156,156,156,156,155,155,154,155,156,155,155,153,153,155,155,156,156,156,154,155,147,145,145,144,145,145,148,148,151,153,153,156,160,160,160,156,151,145,143,143,141,143,144,141,137,134,130,125,125,124,121,121,121,120,120,120,120,118,119,120,119,119,117,116,116,118,120,120,121,122,126,
            128,130,131,131,131,131,132,132,135,137,137,139,140,141,141,143,144,145,147,148,147,147,145,144,144,143,144,144,144,143,144,141,139,137,136,135,137,140,141,143,143,141,141,140,140,140,140,141,141,143,144,144,144,143,143,143,144,145,145,147,148,150,151,151,151,150,150,148,147,145,145,145,145,144,143,143,141,141,141,143,143,145,147,148,148,148,148,148,148,148,148,150,148,148,147,147,147,147,147,147,
            147,147,147,147,147,147,147,147,145,145,144,144,144,144,144,144,144,145,145,145,147,147,148,148,148,148,148,150,148,148,150,150,151,151,151,151,151,151,151,153,151,148,148,148,148,148,148,147,147,147,147,145,145,144,144,144,144,144,144,145,145,144,144,143,144,144,144,144,144,144,145,145,145,147,147,148,148,148,148,148,150,147,148,150,150,150,151,151,150,150,151,151,151,151,148,145,144,145,147,148,
            150,151,151,151,151,148,148,150,150,150,148,148,148,148,148,148,151,151,153,153,153,151,153,153,153,155,155,156,156,155,154,155,153,151,155,156,158,158,158,161,161,163,163,163,161,161,163,163,163,165,165,167,163,156,153,148,143,141,139,137,137,135,134,132,132,132,132,132,134,135,135,136,137,137,139,140,140,141,141,141,144,144,145,147,148,148,150,150,150,151,151,151,151,151,151,151,153,151,153,151,
            151,150,150,148,147,147,147,145,144,143,143,141,141,140,140,140,140,140,140,139,139,139,137,137,137,136,135,135,134,134,134,134,132,131,130,130,129,131,132,134,134,135,135,135,135,134,132,132,132,134,134,134,135,135,135,136,137,139,139,140,139,140,140,140,140,140,139,139,139,139,137,137,136,136,136,136,136,136,136,135,135,136,136,137,137,137,137,137,137,139,139,135,134,134,134,135,136,137,137,136,
            136,136,137,137,137,139,139,139,137,137,136,135,134,134,135,136,136,136,137,137,137,139,139,139,140,140,140,140,140,140,140,141,141,141,141,141,140,140,140,140,141,141,141,141,141,141,141,143,144,145,145,145,144,144,143,143,143,143,143,143,143,143,144,144,144,144,144,144,145,145,145,147,147,148,150,150,148,147,147,147,145,144,145,145,144,145,145,145,147,147,147,147,147,148,150,150,150,151,150,148,
            148,150,150,151,151,150,148,148,148,150,150,150,150,150,148,148,148,148,148,148,148,148,148,147,147,147,147,148,148,148,150,148,148,148,150,148,148,148,148,150,150,150,151,150,150,148,148,148,150,151,151,151,151,151,151,150,150,148,148,148,147,150,150,150,148,150,150,148,148,148,148,148,148,147,148,147,147,147,147,148,148,148,148,148,148,150,150,150,150,150,151,151,150,151,151,151,151,153,151,151,
            151,151,151,151,151,151,151,151,150,150,150,151,153,153,153,153,153,155,155,153,153,153,151,150,150,150,150,150,150,150,150,150,148,150,150,151,151,151,151,151,150,150,148,148,148,148,148,148,150,150,151,151,151,151,151,148,150,150,150,150,150,150,150,150,150,150,150,150,150,148,150,150,151,151,150,150,150,150,150,150,150,150,151,153,153,151,151,151,151,151,151,151,151,150,148,147,145,145,145,145,
            145,145,147,148,150,153,151,151,151,151,151,153,153,153,155,153,153,151,150,150,148,148,148,148,150,150,148,150,148,151,153,155,153,151,153,153,153,151,151,153,153,151,150,151,151,150,151,151,151,151,151,150,148,155,153,151,148,148,151,153,151,148,147,147,147,147,147,150,151,151,151,153,151,151,151,151,151,155,155,151,151,151,151,151,151,151,153,151,150,153,153,153,153,153,153,153,153,155,156,156,
            154,153,155,153,151,151,151,151,150,150,150,148,150,150,148,148,148,153,153,151,151,150,148,148,147,150,151,151,151,151,153,155,153,155,154,155,155,156,156,158,158,156,153,153,153,153,153,153,153,153,151,151,148,148,150,151,151,150,148,148,147,145,144,145,147,145,145,145,147,148,147,147,145,144,144,144,143,143,143,144,144,144,143,144,144,145,145,145,147,147,147,147,147,148,151,148,148,148,150,150,
            148,147,147,147,147,148,148,148,148,150,148,147,145,145,145,145,144,145,145,145,144,144,145,150,150,150,151,153,154,153,153,153,155,156,158,160,158,158,153,151,151,153,150,148,148,151,153,155,156,156,156,155,155,153,151,151,150,148,145,145,145,145,144,143,141,140,139,139,137,137,136,136,136,136,136,136,136,135,135,132,131,130,127,124,122,120,122,122,124,126,129,134,136,137,140,139,136,134,132,132
    };
    uint8_t src4[1200];
    for (int i = 9; i < 1200 ;i++){
        src4[i] = static_cast<uint8_t>(src3[i]);
    }
    auto *fc = new FicherCalc(src4, nullptr, 1200, false);
    fc->calcAll();
    cout<<fc->getBaselineFreq()<<endl;
 */
#include <cstring>
#include "FischerCalc.h"

FicherCalc::FicherCalc(uint8_t *fhrSource, uint8_t *tocoSource, int count, bool hasToco) : FHR_Legnth(count), noTocoData(!hasToco)
{
    FHR_Orignal = new uint8_t[FHR_Legnth];
    Data_store = new uint8_t[FHR_Legnth];

    REFERENCE = new uint16_t[FHR_Legnth];
    FHR_BASELINE = new uint16_t[FHR_Legnth];

    TOCO_Orignal = new uint8_t[FHR_Legnth];
    TOCO_process = new uint8_t[FHR_Legnth];
    TOCO_Clear = new uint8_t[FHR_Legnth];

    FHR_conmbine = new int[FHR_Legnth];
    FHR_frequency = new int[FHR_Legnth];

    Monitor_time = count / 60;
    if(fhrSource)
    {
        for (int i = 0; i < count; ++i)
        {
            FHR_Orignal[i] = fhrSource[i];
        }
    }
    if(hasToco)
    {
        for (int i = 0; i < count; ++i)
        {
            TOCO_Orignal[i] = tocoSource[i];
        }
    }
}

FicherCalc::~FicherCalc()
{
    delete[] FHR_Orignal;
    delete[] Data_store;
    delete[] REFERENCE;
    delete[] FHR_BASELINE;
    delete[] TOCO_Orignal;
    delete[] TOCO_process;
    delete[] TOCO_Clear;
    delete[] FHR_conmbine;
    delete[] FHR_frequency;
    delete[] speed_max_dot;
    delete[] speed_max;
    delete[] speed_min_dot;
    delete[] speed_min;
    delete[] TOCO_peak;
    delete[] TOCO_Amp;
}

/**
 * 计算（1）胎心率基线
 * @return
 */
void FicherCalc::calcBaseLineFreq()
{

    for (int i = 0; i < FHR_Legnth - 1; i++)
    {
        Data_store[i] = FHR_Orignal[i];   //将原始数据转移到基线运算数组中
    }

    //冒泡法进行排序，按照心率从大到小进行排列
    for (int i = 0; i < FHR_Legnth - 1; i++)
    {
        for (int j = 0; j < FHR_Legnth - 1 - i; j++)
        {
            if (Data_store[j] < Data_store[j + 1])
            {
                uint8_t temp = Data_store[j + 1];
                Data_store[j + 1] = Data_store[j];
                Data_store[j] = temp;
            }
        }
    }

    int frequece_add = 1;                   //记录每个不同心率出现的次数
    int frequece_count = 0;                 //统计有多少个不同的心率值
    for (int i = 0; i < FHR_Legnth - 1; i++)
    {
        if (Data_store[i] != Data_store[i + 1])
        {
            FHR_frequency[frequece_count] = frequece_add;  //该数组存储每个心率数值的出现次数
            FHR_conmbine[frequece_count] = Data_store[i];  //该数据记录有多少不同的心率值
            frequece_add = 1;
            frequece_count++;
        } else
        {
            frequece_add++;
        }
    }
    //分别统计出有多少不同的心率值以及出现频次

    for (int i = 0; i < frequece_count - 1; i++)
    {
        for (int j = 0; j < frequece_count - 1 - i; j++)
        {
            if (FHR_frequency[j + 1] > FHR_frequency[j])
            {
                int temp = FHR_frequency[j + 1];
                FHR_frequency[j + 1] = FHR_frequency[j];
                FHR_frequency[j] = temp;

                temp = FHR_conmbine[j + 1];
                FHR_conmbine[j + 1] = FHR_conmbine[j];
                FHR_conmbine[j] = temp;
            }
        }
    }

    //将每个心率值出现的频次从大到小排列，对应的心率数据也排列，这样便于进行统计
    int Max_Value1 = FHR_conmbine[0];
    int Max_Value2 = FHR_conmbine[1];
    int Max_Value3 = FHR_conmbine[2];

    //选择三个出现频率为前三位的心率值，然后看哪个穿越胎心曲线的次数多，就选择哪个作为基线
    int Compare_front = 0;
    int Compare_back = 0;
    int Max1_count = 0;
    int Max2_count = 0;
    int Max3_count = 0;

    for (int i = 1; i < FHR_Legnth - 1; i++)
    {
        if (FHR_Orignal[i] == Max_Value1)
        {
            Compare_front = FHR_Orignal[i - 1] - Max_Value1;
            Compare_back = FHR_Orignal[i + 1] - Max_Value1;
            if (Compare_front * Compare_back <= 0)
            {
                Max1_count++;
            }
        } else
        {
            if (FHR_Orignal[i] == Max_Value2)
            {
                Compare_front = FHR_Orignal[i - 1] - Max_Value2;
                Compare_back = FHR_Orignal[i + 1] - Max_Value2;
                if (Compare_front * Compare_back <= 0)
                {
                    Max2_count++;
                }
            } else
            {
                if (FHR_Orignal[i] == Max_Value3)
                {
                    Compare_front = FHR_Orignal[i - 1] - Max_Value3;
                    Compare_back = FHR_Orignal[i + 1] - Max_Value3;
                    if (Compare_front * Compare_back <= 0)
                    {
                        Max3_count++;
                    }
                }
            }
        }
    }
    //将三个出现频率为前三位的心率值进行穿越率比较，Max？_count为其穿越频次
    if (Max1_count > Max2_count)
    {
        if (Max1_count > Max3_count)
        {
            Frequency_max = Max_Value1;
        } else
        {
            Frequency_max = Max_Value3;
        }
    } else
    {
        if (Max2_count > Max3_count)
        {
            Frequency_max = Max_Value2;
        } else
        {
            Frequency_max = Max_Value3;
        }
    }
}

/**
 * 计算（2）变异幅度
 * @return
 */
void FicherCalc::calcThinvari()
{
    int min = FHR_Legnth / 60;
    int p = FHR_Legnth % 60;
    if(p > 0)
        min = min+1;

    uint8_t Baseline_change[min];      //记录每一分钟胎心率的最大值和最小值之差
    memset(Baseline_change, 0, min);

    uint8_t Value_max = 0;
    uint8_t Value_min = 255;

    for (int i = 0; i < min; i++)
    {
        for (int j = 60 * i; j < 60 * (i + 1); j++)
        {
            if(j >= FHR_Legnth) break;

            if(Value_max == 0 && Value_min == 255)
                Value_max = Value_min = FHR_Orignal[j];

            if (FHR_Orignal[j] > Value_max)
            {
                Value_max = FHR_Orignal[j];
            }

            if (FHR_Orignal[j] < Value_min)
            {
                Value_min = FHR_Orignal[j];
            }
        }
        Baseline_change[i] = Value_max - Value_min;
        Value_max = 0;
        Value_min = 255;
    }

    for (int i = 0; i < min; i++)
    {
        if (Baseline_change[i] > Baseline_shake)
        {
            Baseline_shake = Baseline_change[i];           //Baseline_shake即为幅度变异的值
        }
    }
}

/**
 * 计算（3）变异频率
 * @return
 */
void FicherCalc::calcVariFreq()
{
    int min = FHR_Legnth / 60;
    int p = FHR_Legnth % 60;
    if(p > 0)
        min = min+1;

    uint8_t Frequency_change[min];
    uint8_t frequncy_count = 0;

    int rate_cal;
    int TRANS_1;
    int TRANS_2;
    int TRANS_3;

    REFERENCE[FHR_Legnth - 1] = FHR_Orignal[FHR_Legnth - 1];
    //前向滤波
    for (int i = 0; i < FHR_Legnth - 1; i++)
    {
        REFERENCE[FHR_Legnth - 2 - i] = static_cast<uint16_t>(0.6f * REFERENCE[FHR_Legnth - 1 - i] + 0.4f * FHR_Orignal[FHR_Legnth - 2 - i]);
    }
    //后向滤波，REFERENC[]为原曲线滤波拟合值，用于判断拐点
    for (int i = 1; i < FHR_Legnth; i++)
    {
        REFERENCE[i] = static_cast<uint16_t>(0.6f * REFERENCE[i - 1] + 0.4f * REFERENCE[i]);
    }
    for (int i = 0; i < min; i++)
    {
        frequncy_count = 0;
        for (int j = 60 * i + 1; j < 60 * (i + 1) - 1; j++)
        {
            if(j >= FHR_Legnth) break;

            TRANS_1 = REFERENCE[i - 1];
            TRANS_2 = REFERENCE[i];
            TRANS_3 = REFERENCE[i + 1];
            rate_cal = (TRANS_1 - TRANS_2) * (TRANS_2 - TRANS_3);    //是否是拐点
            if (rate_cal < 0)
            {
                if (REFERENCE[i] > REFERENCE[i - 1])
                {
                    frequncy_count++;
                }
            } else
            {
                if (rate_cal == 0)
                {
                    if (REFERENCE[i] == REFERENCE[i - 1])
                    {
                        if (REFERENCE[i] > REFERENCE[i + 1])
                        {
                            frequncy_count++;
                        }
                    }
                }
            }
        }
        Frequency_change[i] = frequncy_count;
    }

    for (int i = 0; i < min; i++)
    {
        if (Frequency_change[i] > Frequency_shake)
        {
            Frequency_shake = Frequency_change[i];           //测出拐点，Frequency_shake即为变异频率
        }
    }
}

/**
 * 计算加速次数
 * @return
 */
void FicherCalc::calcAcce()
{
    uint16_t FHR_first[40];                  //加速区起始点
    uint16_t FHR_last[40];                  //加速区终止点

    FHR_BASELINE[FHR_Legnth-1] = static_cast<uint16_t>(0.975 * FHR_Orignal[FHR_Legnth - 1] + 0.025 * Frequency_max);
    //找出首值

    for(int i=0;i<FHR_Legnth-1;i++)
    {
        FHR_BASELINE[FHR_Legnth-2-i]= static_cast<uint16_t>(0.975 * FHR_BASELINE[FHR_Legnth - 1 - i] + 0.025 * FHR_Orignal[FHR_Legnth - 2 - i]); //前向滤波
    }

    for(int i=1;i<FHR_Legnth;i++)
    {
        FHR_BASELINE[i]= static_cast<uint16_t>(0.975 * FHR_BASELINE[i - 1] + 0.025 * FHR_BASELINE[i]);            //后向滤波
    }

    for(int i=0;i<FHR_Legnth;i++)
    {
        FHR_BASELINE[i] = static_cast<uint16_t>(0.9 * Frequency_max + 0.1 * FHR_BASELINE[i]);                    //基线修正
    }

    REFERENCE[FHR_Legnth-1] = static_cast<uint16_t>(FHR_Orignal[FHR_Legnth - 1]);                          //找出首值
    for(int i=0;i<FHR_Legnth-1;i++)
    {
        REFERENCE[FHR_Legnth-2-i]= static_cast<uint16_t>(0.92 * REFERENCE[FHR_Legnth - 1 - i] + 0.08 * FHR_Orignal[FHR_Legnth - 2 - i]);         //前向滤波
    }

    for(int i=1;i<FHR_Legnth;i++)
    {
        REFERENCE[i]= static_cast<uint16_t>(0.92 * REFERENCE[i - 1] + 0.08 * REFERENCE[i]);                       //后向滤波
    }

    //*********************************************************************
    //计算加速幅度超过15秒，持续时间超过4秒的区段
    //*********************************************************************
    uint8_t next_add = 0;                                  //加速区的长度
    uint8_t speedup = 0;
    int tran_data = 0;                                //加速区标志
    int tran_data2 = 0;                               //用于将无符号数变成有符号数
    int record = 0;
    for (int i = 0; i < FHR_Legnth; i++)
    {
        tran_data = FHR_Orignal[i];
        tran_data2 = FHR_BASELINE[i];
        if (speedup == 0)                              //未在加速区内
        {
            if (tran_data - tran_data2 > 15)
            {
                speedup = 1;                            //进入疑似加速区
                record = i;                             //记录第一个大于15的值
                next_add = 1;                           //长度计数清零
            }
        } else                                        //在加速区内
        {
            if (tran_data - tran_data2 > 15)
            {
                next_add++;
            } else                                      //加速结束
            {
                speedup = 0;
                if (next_add > 4)                          //超过15s的时间超过了4秒
                {
                    FHR_first[speedup_count] = record;
                    FHR_last[speedup_count] = i;
                    speedup_count++;                      //speedup_count是统计疑似加速的区间
                }
            }
        }
    }

    //*********************************************************************
    //计算加速区间的起始和终止点
    //*********************************************************************
    uint16_t frist_point;
    uint16_t end_point;
    uint8_t begin_OK = 0;
    int rate;
    int DATA_TRANS1;
    int DATA_TRANS2;                               //将无符号数变换为有符号数
    int DATA_TRANS3;
    int DATA_TRANS4;
    int DATA_TRANS5;
    for (int i = 0; i < speedup_count; i++)
    {
        frist_point = FHR_first[i];
        end_point = FHR_last[i];
        begin_OK = 0;
        while (begin_OK == 0)
        {
            if (frist_point == 0)
            {
                begin_OK = 1;
                FHR_first[i] = 0;
                break;
            } else
            {
                DATA_TRANS1 = REFERENCE[frist_point];
                DATA_TRANS2 = REFERENCE[frist_point - 1];
                DATA_TRANS3 = REFERENCE[frist_point + 1];
                DATA_TRANS4 = FHR_BASELINE[frist_point];
                DATA_TRANS5 = FHR_Orignal[frist_point];
                rate = (DATA_TRANS1 - DATA_TRANS2) * (DATA_TRANS3 - DATA_TRANS1);
                if (rate <= 0)
                    //当检测到拐点，然后算间隔是否小于5
                {
                    if (DATA_TRANS1 - DATA_TRANS4 < 5)           //拟合点与基线差距不超过4
                    {
                        begin_OK = 1;                              //跳出循环
                        FHR_first[i] = frist_point;
                    }
                } else
                {
                    if (DATA_TRANS5 <= DATA_TRANS4)            //没有拐点的情况下，检测曲线点与基线相交
                    {
                        begin_OK = 1;
                        FHR_first[i] = frist_point;
                    }
                }
            }
            frist_point--;                                      //FHR_first中存放的都是加速起始点
        }
        begin_OK = 0;
        while (begin_OK == 0)
        {
            if (end_point == FHR_Legnth - 1)
            {
                FHR_last[i] = FHR_Legnth - 1;
                begin_OK = 1;
                break;
            } else
            {
                DATA_TRANS1 = REFERENCE[frist_point];
                DATA_TRANS2 = REFERENCE[frist_point - 1];
                DATA_TRANS3 = REFERENCE[frist_point + 1];
                DATA_TRANS4 = FHR_BASELINE[frist_point];
                DATA_TRANS5 = FHR_Orignal[frist_point];
                rate = (DATA_TRANS1 - DATA_TRANS2) * (DATA_TRANS3 - DATA_TRANS1);
                if (rate <= 0)
                    //当检测到拐点，然后算间隔是否小于5
                {
                    if (DATA_TRANS1 - DATA_TRANS4 < 5)                       //拟合点与基线差距不超过4
                    {
                        begin_OK = 1;                                          //跳出循环
                        FHR_last[i] = end_point;
                    }
                } else
                {
                    if (DATA_TRANS5 <= DATA_TRANS4)                        //曲线点与基线相交
                    {
                        begin_OK = 1;
                        FHR_last[i] = end_point;
                    }
                }
                end_point++;
                //FHR_last中存放的都是加速结束点
            }
        }

        for (int j = 0; j < speedup_count; j++)
        {
            if (FHR_last[j] - FHR_first[j] > 15)//加速起始到加速结束的时间需要超过15秒才能算一次加速
            {
                FHR_last[real_speedup_count] = FHR_last[j];
                FHR_first[real_speedup_count] = FHR_first[j];
                //将真正的属于加速的区间定为加速区间
                real_speedup_count++;
                //real_speedup_count是真正的加速次数
            }
        }
    }

    uint8_t jizhimax;
    uint32_t jizhi_count = 1;                                                 //统计一段区间内有多少个相同的最高值

    if (real_speedup_count > 0)                                           //如果存在加速区间，那么进行下一步，否则无减速
    {
        speed_max_dot = new int[real_speedup_count];
        speed_max = new int[real_speedup_count];
        for (int i = 0; i < real_speedup_count; i++)                      //一段加速区间只能有一个极值
        {
            jizhimax = 0;
            for (int j = FHR_first[i]; j <= FHR_last[i]; j++)             //在一段加速区间搜索最大值
            {
                if (FHR_Orignal[j] > jizhimax)                            //当发现有比最小值还小的
                {
                    jizhimax = FHR_Orignal[j];                            //将极大值记录下来，并向后对比
                    speed_max_dot[i] = j;                                 //求出一段区间内的最大加速点的位置
                    jizhi_count = 1;
                } else
                {
                    if (FHR_Orignal[j] == jizhimax)
                    {
                        speed_max_dot[i] += j;
                        jizhi_count++;
                    }
                }
            }
            speed_max_dot[i] /= jizhi_count;                             //speed_max_dot[]存储的是加速区顶部的位置
            speed_max[i] = jizhimax;                                     //speed_max[]存储的是加速区顶部的幅值
        }
    }
}

/***
 * 计算减速
 */
void FicherCalc::calcDec()
{
    //******************************下面开始判断减速区************************************
    uint8_t next_dec = 0;                                  //减速区的长度

    uint8_t speeddown = 0;                               //减速区标志
    int record = 0;                                    //记录有几次减速
    uint16_t speeddown_begin[20] = {0};                      //减速区的起始点
    uint16_t speeddown_end[20] = {0};                        //减速区的终点

    int data_tran;                                  //用于将非符号数转变为符号数，避免做减法溢出
    int data_tran2;

    for (int i = 0; i < FHR_Legnth; i++)
    {
        data_tran = FHR_BASELINE[i];
        data_tran2 = FHR_Orignal[i];
        if (speeddown == 0)                            //未在减速区内
        {
            if (data_tran - data_tran2 > 15)                  //发现有减速超过15bpm的数值，向后看持续时间
            {
                speeddown = 1;                          //进入疑似加速区
                record = i;                              //记录第一个大于15的值
                next_dec = 1;                           //长度计数清零
            }
        } else                                        //在减速区内
        {
            if (data_tran - data_tran2 > 15)
            {
                next_dec++;
            } else                                      //减速结束
            {
                speeddown = 0;
                if (next_dec > 4)                          //时长是否大于4s
                {
                    speeddown_begin[speeddown_count] = record;
                    speeddown_end[speeddown_count] = i;
                    speeddown_count++;          //speeddown_count为疑似减速的次数，确切减速需要进一步验证
                }
            }
        }
    }

    //*****************************计算真正的减速区**********************************************
    uint16_t frist_point = 0;
    uint16_t end_point = 0;
    uint8_t begin_OK = 0;
    int rate;
    int rate1;
    int rate2;
    int rate3;
    int rate4;
    int rate5;
    uint16_t Dec_count;

    REFERENCE[FHR_Legnth - 1] = FHR_Orignal[FHR_Legnth - 1];               //赋首值
    for (int i = 0; i < FHR_Legnth - 1; i++)
    {
        REFERENCE[FHR_Legnth - 2 - i] = static_cast<uint16_t>(0.9 * REFERENCE[FHR_Legnth - 1 - i] +0.1 * FHR_Orignal[FHR_Legnth - 2 - i]);
    }                                   //前向滤波
    for (int i = 1; i < FHR_Legnth; i++)
    {
        REFERENCE[i] = static_cast<uint16_t>(0.9 * REFERENCE[i - 1] + 0.1 * REFERENCE[i]);               //做原曲线的拟合曲线
    }

    for (int i = 0; i < speeddown_count; i++)               //计算每一段减速区间的起始点和终点
    {
        frist_point = speeddown_begin[i];
        end_point = speeddown_end[i];
        begin_OK = 0;
        while (begin_OK == 0)
        {
            if (frist_point == 0)                       //如果第0点就是起始点
            {
                begin_OK = 1;                       //跳出循环
                speeddown_begin[i] = 0;
                break;
            } else
            {
                rate1 = REFERENCE[frist_point];
                rate2 = REFERENCE[frist_point - 1];
                rate3 = REFERENCE[frist_point + 1];
                rate4 = FHR_BASELINE[frist_point];
                rate5 = FHR_Orignal[frist_point];
                rate = (rate1 - rate2) * (rate3 - rate1);                     //先用拟合值去减基线
                if (rate <= 0)                                      //如果是极值点，那么判断
                {
                    if (rate4 - rate1 < 5)                                //拐点与基线差距不超过4
                    {
                        begin_OK = 1;                               //跳出循环
                        speeddown_begin[i] = frist_point;
                    }
                } else                                             //不是极值点
                {
                    if (rate5 >= rate4)                                 //原始值与基线相交
                    {
                        begin_OK = 1;                                //跳出循环
                        speeddown_begin[i] = frist_point;
                    }
                }
            }
            frist_point--;                                        //speeddown_begin中存放的都是减速起始点
        }
        begin_OK = 0;
        while (begin_OK == 0)
        {
            if (end_point == FHR_Legnth - 1)                          //如果最后一点就是终点
            {
                begin_OK = 1;                                     //跳出循环
                speeddown_end[i] = 0;
                break;
            } else
            {
                rate1 = REFERENCE[frist_point];
                rate2 = REFERENCE[frist_point - 1];
                rate3 = REFERENCE[frist_point + 1];
                rate4 = FHR_BASELINE[frist_point];
                rate5 = FHR_Orignal[frist_point];
                rate = (rate1 - rate2) * (rate3 - rate1);                      //先用拟合值去减基线
                if (rate <= 0)                                        //检测到拐点
                {
                    if (rate4 - rate1 < 5)                                 //拐点与基线相差不超过4
                    {
                        begin_OK = 1;                                //跳出循环
                        speeddown_end[i] = end_point;
                    }
                } else                                    //如果斜率不为零，那么判断原始线和基线是否相交
                {
                    if (rate5 >= rate4)                        //原始胎心曲线与基线相交
                    {
                        begin_OK = 1;                       //跳出循环
                        speeddown_end[i] = end_point;         //将减速区终点重新置入speeddown_end寄存器中
                    }
                }
            }
            end_point++;                              //speeddown_end中存放的都是减速区终点
        }
    }
    if(speeddown_count > 0)
    {
        speed_min = new int[speeddown_count];

        for (int i = 0; i < speeddown_count; i++)
        {
            if (speeddown_end[i] - speeddown_begin[i] > 15)     //减速起始到减速结束的时间需要超过15秒才算
            {
                speeddown_end[real_speeddown] = speeddown_end[i];
                speeddown_begin[real_speeddown] = speeddown_begin[i];    //将真正的属于减速的区间定为减速区间
                speed_min[real_speeddown] = speed_min[i];
                real_speeddown++;                                   //real_speeddown是真正的减速次数
            }
        }
        uint32_t jizhimin = 0;
        uint32_t jizhi_count = 1;                               //统计一段区间内有多少个相同的最高值
        if (real_speeddown > 0)                           //如果存在减速区间，那么进行下一步，否则无减速
        {
            speed_min_dot = new int[real_speeddown];
            for (int i = 0; i < real_speeddown; i++)                  //一段减速区间只能有一个极值
            {
                jizhimin = 0;
                for (int j = speeddown_begin[i]; j <= speeddown_end[i]; j++)  //在一段减速区间搜索最小值
                {
                    if (FHR_Orignal[j] < jizhimin)                      //当发现有比最小值还小的
                    {
                        jizhimin = FHR_Orignal[j];                     //将极小值记录下来，并向后对比
                        speed_min_dot[i] = j;                          //求出一段区间内的最大减速点的位置
                        jizhi_count = 1;
                    } else
                    {
                        if (FHR_Orignal[j] == jizhimin)
                        {
                            speed_min_dot[i] += j;
                            jizhi_count++;
                        }
                    }
                }
                speed_min_dot[i] /= jizhi_count;                  //speed_min_dot[]存储的是减速区底部的位置
                speed_min[i] = jizhimin;                       //speed_min[]存储的是减速区底部的幅值
            }
        }

    }

    int Clear_Position[40]={0};             //Clear_Position是存储清零点位置的寄存器
    uint8_t Clear_count = 0;                   //记录有多少个清零点
    uint8_t Clear_Value = 0;
    uint32_t TOCO_begin[20]={0};
    uint32_t TOCO_end[20]={0};               //用于统计宫缩区间顶端有一段是100的

    uint8_t TOCO_flag = 0;
    uint8_t Dot_count = 0;
    uint32_t Begin_record;

    if(!noTocoData)
    {
        TOCO_process[FHR_Legnth - 1] = TOCO_Orignal[FHR_Legnth - 1];
        for (int i = 0; i < FHR_Legnth - 1; i++)
        {
            TOCO_process[FHR_Legnth - 2 - i] = static_cast<uint8_t>(0.9f* TOCO_Orignal[FHR_Legnth - 1 - i] + 0.1f * TOCO_Orignal[FHR_Legnth - 2 - i]);
        }                                                                  //前向滤波
        for (int i = 1; i < FHR_Legnth; i++)
        {
            TOCO_process[i] = static_cast<uint8_t>(0.9 * TOCO_process[i - 1] + 0.1 * TOCO_process[i]);          //做TOCO曲线的拟合曲线
        }

        for (int i = 0; i < FHR_Legnth; i++)                   //看有多少个清零的标志，位置在哪里
        {
            if (TOCO_Clear[i] > 0)
            {
                Clear_count++;
                Clear_Position[Clear_count] = i;
            }
        }

        if (Clear_count > 0)                       //当发现有清零的操作，就要把之前的TOCO曲线的值全部降低，
        {
            for (int i = 1; i <= Clear_count; i++)
            {
                Clear_Value = TOCO_Orignal[Clear_Position[i] - 1];   //前一秒的数值小于3，怕是噪声，再往前推一个
                if (Clear_Value < 3)
                {
                    Clear_Value = TOCO_Orignal[Clear_Position[i] - 2]; //再前一秒的数值仍小于3，那就确定确实是小于3
                }
                for (int j = Clear_Position[i - 1] + 1; j < Clear_Position[i]; j++)
                {
                    if (TOCO_Orignal[j] > Clear_Value)
                    {
                        TOCO_Orignal[j] -= Clear_Value;
                    } else
                    {
                        TOCO_Orignal[j] = 0;
                    }
                }
            }
        }

        for (int i = 0; i < FHR_Legnth - 1; i++)
        {
            if (TOCO_flag == 0)
            {
                if (TOCO_process[i] > 20)
                {
                    Dot_count = 0;
                    TOCO_flag = 1;
                    Begin_record = i;
                }
            } else
            {
                if (TOCO_process[i] > 20)
                {
                    Dot_count++;
                } else
                {
                    TOCO_flag = 0;
                    if (Dot_count > 20)                        //超过基线20，持续时间超过20s，视为一次宫缩时间
                    {
                        TOCO_begin[TOCO_count] = Begin_record;
                        TOCO_end[TOCO_count] = i;
                        TOCO_count++;
                        //TOCO_count即为宫缩的次数，如果TOCO_count=0，说明没有宫缩，那么减速全部都是变异减速VD
                    }
                }
            }
        }

        uint8_t same_TOCO = 0;
        uint8_t TOCO_Max = 0;
        uint32_t TOCO_Position;
        if (TOCO_count > 0)                              //如果存在宫缩，计算其顶峰和
        {
            TOCO_peak = new int[TOCO_count];
            TOCO_Amp = new int[TOCO_count];
            for (int i = 0; i < TOCO_count; i++)
            {
                for (int j = TOCO_begin[i]; j < TOCO_end[i]; j++)
                {
                    if (TOCO_Orignal[j] > TOCO_Max)
                    {
                        TOCO_Max = TOCO_Orignal[j];
                        TOCO_Position = j;
                        same_TOCO = 1;
                    } else
                    {
                        if (TOCO_Orignal[j] == TOCO_Max)
                        {
                            same_TOCO++;
                            TOCO_Position += j;
                        }
                    }
                }
                TOCO_peak[i] = TOCO_Position / same_TOCO;     //峰值的位置
                TOCO_Amp[i] = TOCO_Max;                     //峰值的幅值,
            }
        }

        if (real_speeddown > 0)                                 //肯定要有确定的减速区间才能进行这一步运算
        {
            for (int i = 0; i < TOCO_count; i++)
            {
                for (int j = 0; j < real_speeddown; j++)
                {
                    if (speed_min_dot[j] >= TOCO_peak[i] - 4)           //减速曲线时间一般要晚于TOCO曲线峰值，但是怕计算问题，所以留4秒的余量
                    {
                        if (speed_min_dot[j] < TOCO_peak[i] + 15)         //早期减速曲线不晚于TOCO峰值的15秒
                        {
                            if (speed_min_dot[j] - speeddown_begin[j] > 30) //减速起点到波谷的时间不小于30秒
                            {
                                ED_count++;
                                j = real_speeddown;
                            }
                        } else
                        {
                            if (speed_min_dot[j] < TOCO_peak[i] + 60)       //晚期减速曲线不晚于TOCO峰值的60秒内
                            {
                                if (speed_min_dot[j] > TOCO_peak[i] + 30)     //但是又要大于TOCO峰值的30秒
                                {
                                    if (speed_min_dot[j] - speeddown_begin[j] > 30)  //减速起点到波谷的时间要不小于30秒
                                    {
                                        LD_count++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    //如果没有使用宫缩探头，那么ED_count和LD_count都为0
    if (ED_count > 0)          //如果有早发减速，那么肯定没有变异减速
    {
        VD_count = 0;
    } else
    {
        if (LD_count > 0)        //如果有迟发减速，那么肯定也没有变异减速
        {
            VD_count = 0;
        } else            //早发减速和迟发减速都没有，那么剩下的都是变异减速，那么还要排除重度变异减速
        {
            for (int i = 0; i < real_speeddown; i++)                      //检查有无重度变异减速
            {
                Dec_count = speeddown_end[i] - speeddown_begin[i];
                if (Dec_count >= 120)                            //减速持续时间超过120s，视为PD，即延长减速
                {
                    PD_count++;
                } else
                {
                    if (Dec_count >= 60)
                    {
                        if (speed_min[i] <= 70)
                        {
                            VD_PLUS_count++;       //减速时间超过60秒，减速幅度低于70bpm，视为重度变异减速
                        }
                    }
                }
            }
            VD_count = real_speeddown - VD_PLUS_count - PD_count;
        }
    }
}

void FicherCalc::calcAll()
{
    calcBaseLineFreq();
    calcThinvari();
    calcVariFreq();
    calcAcce();
    calcDec();
}

int FicherCalc::getBaselineFreq()
{
    return Frequency_max;
}

int FicherCalc::getThinvari()
{
    return Baseline_shake;
}

int FicherCalc::getVarirFreq()
{
    return Frequency_shake;
}

int FicherCalc::getAcce()
{
    return real_speedup_count;
}

int FicherCalc::getDec()
{
    return real_speeddown;
}

int FicherCalc::getED()
{
    return noTocoData ? 0 : ED_count;
}

int FicherCalc::getLD()
{
    return noTocoData ? 0 : LD_count;
}

int FicherCalc::getVD()
{
    return VD_count;
}

int FicherCalc::getVDp()
{
    return noTocoData ? 0 : VD_count;
}

int FicherCalc::getPD()
{
    return noTocoData ? 0 : VD_count;
}

int *FicherCalc::getAcceMaxPosi()
{
    return speed_max_dot;
}

int *FicherCalc::getAcceMax()
{
    return speed_max;
}

int *FicherCalc::getDecMinPosi()
{
    return speed_min_dot;
}

int *FicherCalc::getDecMin()
{
    return speed_min;
}

int *FicherCalc::getTocoPeekPosi()
{
    return TOCO_peak;
}

int *FicherCalc::getTocoPeek()
{
    return TOCO_Amp;
}

int FicherCalc::getTocoCount()
{
    return TOCO_count;
}

